package org.puppet.demo.mario;

import org.puppet.demo.tank.R;
import org.puppet.game.base.PuppetUtils;
import org.puppet.game.element.Puppet;
import org.puppet.game.element.PuppetInfo;
import org.puppet.game.element.PuppetInfo.AnimInfo;

import android.content.Resources;

public class Mario extends Puppet {

	private static int ANI_STAND = 0;
	private static int ANI_WALK = 1;

	private boolean isJumping = false;
	private boolean isWalking = false;

	@Override
	protected PuppetInfo getAnimationInfo(Resources res) {
		PuppetInfo info = new PuppetInfo();
		info.setBitmap(PuppetUtils.createBitmap(res, R.drawable.mario));
		info.setFrameHeight(30);
		info.setFrameWidth(25);
		
		info.setAnims(new AnimInfo[]{
				new AnimInfo(0, new long[]{1000}, 12, 29),
				new AnimInfo(0, new long[]{50, 50, 50}, 12, 29)
		});
		return info;
	}
	
	public Mario() {
		super();
		changeAnimation(ANI_STAND);
	}

	public void stand() {
		this.vX = 0;
		this.vY = 0;
		this.acceY = 0;
		this.acceX = 0;
		isWalking = false;
		isJumping = false;
		changeAnimation(ANI_STAND);
	}

	public void walk(float vX, float vY) {
		this.vX = vX;
		this.vY = vY;
		isFaceLeft = vX == 0 ? isFaceLeft : (vX < 0);
		isWalking = true;
		isJumping = false;
		changeAnimation(ANI_WALK);
	}

	public void jump(float vX, float vY) {
		this.vX = vX;
		this.vY = vY;
		isFaceLeft = vX == 0 ? isFaceLeft : (vX < 0);
		isWalking = false;
		isJumping = true;
		changeAnimation(ANI_WALK);
	}

	public boolean isWalking() {
		return isWalking;
	}

	public void setWalking(boolean isWalking) {
		this.isWalking = isWalking;
	}

	public boolean isJumping() {
		return isJumping;
	}

	public void setJumping(boolean isJumping) {
		this.isJumping = isJumping;
	}

}
